using System;
using System.Collections.Generic;
using System.Text;

namespace Khanhnt
{
    public class timNghiemBacHai
    {
        private double a;
        private double b;
        private double c;

        public timNghiemBacHai()
        {
            a = 0;
            b = 0;
            c = 0;
        }

        public timNghiemBacHai (double a, double b, double c)
        {
            this.a = a;
            this.b = b;
            this.c = c;
        }

        public void nhapA(String a)
        {
            this.a = double.Parse(a);
        }

        public void nhapB(String b)
        {
            this.b = double.Parse(b);
        }

        public void nhapC(String c)
        {
            this.c = double.Parse(c);
        }

        public double tinhDelta()
        {
            return Math.Pow(b, 2) - 4 * a * c;
        }

        public double tinhNghiem()
        {
            if (a == 0 || b == 0)
            {
                if (c == 0)
                {
                    Console.WriteLine("Phuong trinh vo so nghiem!!");
                    return 0;
                }
                else
                {
                    Console.WriteLine("Phuong trinh vo nghiem!!");
                    return 0;
                }
            }

                return (-b + Math.Sqrt(tinhDelta())) / 2 * a;
        }
    }
}
